<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
$api = app(\Dingo\Api\Routing\Router::class);

$api->version('v1', function ($api){
	//Remind小程序分组，限速100次/分钟
	$api->group([
		'prefix' => 'remind', //项目前缀
		'middleware' => ['api.throttle'],  //限速中间件
		'limit' => 100,
		'expires' => 1,
		'namespace' => '\App\Wechat\Remind\Controllers'  //命名空间
	], function ($api){
		$api->post('/auth/login', 'AuthController@login');
		$api->get('/auth/refresh', 'AuthController@refresh');
		$api->group([
			'middleware' => ['remind.login'],  //自定义认证中间件
		], function ($api){
			$api->get('/user/me', 'UserController@me');
			//remind
			$api->get('/reminds', 'RemindController@index');
			$api->get('/reminds/{id}', 'RemindController@show')->where('id', '^\+?[1-9]\d*$');
			$api->post('/reminds', 'RemindController@store');
			$api->put('/reminds/{id}', 'RemindController@edit')->where('id', '^\+?[1-9]\d*$');
			$api->delete('/reminds/{id}', 'RemindController@delete')->where('id', '^\+?[1-9]\d*$');
			$api->get('/reminds/count', 'RemindController@countRemind');
			//formid
			$api->post('/tickets', 'TicketController@store');
			//user
			$api->get('/user', 'UserController@me');
		});
	});
});

